﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogisticsBLL;
using Model;

namespace WebLosgic
{
    public partial class SysLog : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlBind();
                GetBind();
            }
        }


        public void ddlBind()
        {
            UserBLL ub = new UserBLL();
            DdlType.DataSource = ub.readDDl();
            DdlType.DataTextField = "TypeName";
            DdlType.DataValueField = "TypeID";
            DdlType.DataBind();
            DdlType.Items.Insert(0, new ListItem("请选择", "0"));
        }

        public void GetBind()
        {
            UserBLL ub = new UserBLL();
            SysLogs log = new SysLogs();
            log.TypeID =Convert.ToInt32(DdlType.SelectedValue);
            log.Account = TxtAcount.Text;
            log.CheckInTime = TxtDate.Text;
            log.CheckInTimeEnd = TxtDateEnd.Text;
            log.IsException = Convert.ToInt32(RblISexc.SelectedValue);
            log.ProcName = TxtProcName.Text;
            int PageIndex = AspNetPagerTool.CurrentPageIndex;
            int pageSize = AspNetPagerTool.PageSize;
            int Count = 0;
            RptSysLog.DataSource = ub.BindSysLog(log, PageIndex, pageSize,out Count);
            AspNetPagerTool.RecordCount = Count;
            RptSysLog.DataBind();
        }

        protected void BtnResul_Click(object sender, EventArgs e)
        {
            UserBLL ub = new UserBLL();
            SysLogs log = new SysLogs();
            log.TypeID = Convert.ToInt32(DdlType.SelectedValue);
            log.Account = TxtAcount.Text;
            log.CheckInTime = TxtDate.Text;
            log.CheckInTimeEnd = TxtDateEnd.Text;
            log.IsException = Convert.ToInt32(RblISexc.SelectedValue);
            log.ProcName = TxtProcName.Text;
            int PageIndex = AspNetPagerTool.CurrentPageIndex;
            int pageSize = AspNetPagerTool.PageSize;
            int Count = 0;
            RptSysLog.DataSource = ub.BindSysLog(log, PageIndex, pageSize, out Count);
            AspNetPagerTool.RecordCount = Count;
            RptSysLog.DataBind();
        }


        protected string getcut(string str)
        {
            int len = 10;
            if (str.Length > len)
            {
                return str.ToString().Substring(0, len) + "...";
            }
            else
            {
                return str;
            }
        }

        protected void BtnRoback_Click(object sender, EventArgs e)
        {
            DdlType.SelectedValue = "0";
            TxtAcount.Text = "";
            TxtDate.Text = "";
            TxtDateEnd.Text = "";
            TxtProcName.Text = "";
            RblISexc.SelectedValue = "-1";
        }

        protected void AspNetPagerTool_PageChanged(object sender, EventArgs e)
        {
            GetBind();
        }
    }
}